#!/usr/bin/python3
# -*- coding: utf-8 -*-

from resource_management import *

class PgAdminClient(Script):

    def install(self, env):
        # 安装
        Execute('sudo yum install pgadmin4-web -y',ignore_failures=True)
        print('Success install the pgadmin')

    def configure(self, env):
        print("Nothing needed to do ")

    def stop(self, env):
        print('Nothing needed to do ')

    def start(self, env):
        # 启动
        Execute("sudo /usr/pgadmin4/bin/setup-web.sh", ignore_failures=True)
        print('Nothing needed to do ')

    def status(self, env):
        print('Status of PGADMIN ......')
        try:
            Execute('systemctl status pgadmin')
        except:
            print('PGSQL MASTER IS NOT RUNNING')
            raise ComponentIsNotRunning()


if __name__ == "__main__":
    PgAdminClient().execute()

